home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- BackColor = &H00C0C0C0&
- Caption = "Webster Client"
- ClientHeight = 3360
- ClientLeft = 1065
- ClientTop = 2010
- ClientWidth = 5040
- Height = 3765
- Left = 1005
- LinkTopic = "Form1"
- ScaleHeight = 3360
- ScaleWidth = 5040
- Top = 1665
- Width = 5160
- Begin IPPORT IPPort1
- EOL = ""
- InBufferSize = 2048
- Left = 0
- LocalPort = 0
- OutBufferSize = 2048
- Port = 0
- Top = 1320
- End
- Begin TextBox tDesc
- Height = 2895
- Left = 0
- MultiLine = -1 'True
- ScrollBars = 3 'Both
- TabIndex = 3
- Top = 480
- Width = 5055
- End
- Begin CommandButton bDefine
- Caption = "Define"
- Default = -1 'True
- Height = 375
- Left = 3720
- TabIndex = 2
- Top = 60
- Width = 1215
- End
- Begin TextBox tWord
- Height = 285
- HideSelection = 0 'False
- Left = 720
- TabIndex = 0
- Top = 120
- Width = 2775
- End
- Begin Label Label1
- BackStyle = 0 'Transparent
- Caption = "Word:"
- Height = 255
- Left = 120
- TabIndex = 1
- Top = 150
- Width = 735
- End
- Sub bDefine_Click ()
- IPPort1.EOL = Chr$(10) 'talking text to Unix host
- 'first check for a word
- If Trim$(tWord) = "" Then
- MsgBox "Define what? Please enter a word first..."
- Exit Sub
- End If
- On Error GoTo ErrorHandling
- 'if not connected yet, then connect
- If Not IPPort1.Connected Then
- 'set address and port of webster host in Indiana
- IPPort1.HostAddress = "129.79.254.195"
- IPPort1.Port = 2627
- 'now try to connect
- MousePointer = 11
- tDesc = "Connecting to Webster host..."
- IPPort1.Connected = True
- 'wait for connection to take place
- '(using a timer would be more appropriate here)
- For i = 1 To 500000
- If IPPort1.Connected Then Exit For
- DoEvents
- Next i
- 'connection is taking too long
- If i = 50000 Then
- IPPort1.Connected = False
- MsgBox "Timeout while trying to connect. Please try again later."
- MousePointer = 0
- Exit Sub
- End If
- End If
- 'connection is made, so let's define word
- tDesc = "Making request..."
- IPPort1.DataToSend = "DEFINE " & tWord & Chr$(10)
- Exit Sub
- ErrorHandling:
- MousePointer = 0
- IPPort1.Connected = False
- MsgBox "ERROR: " & Error$
- Exit Sub
- End Sub
- Sub Form_Load ()
- tDesc = Chr$(13) & Chr$(10) & "This is a very simple Webster client." & Chr$(13) & Chr$(10)
- tDesc = tDesc & Chr$(13) & Chr$(10) & "It connects to a dictionary host in Indiana." & Chr$(13) & Chr$(10)
- tDesc = tDesc & Chr$(13) & Chr$(10) & "You can enter text above, or just" & Chr$(13) & Chr$(10)
- tDesc = tDesc & Chr$(13) & Chr$(10) & "doubleclick a word here."
- End Sub
- Sub Form_Resize ()
- tDesc.Width = ScaleWidth
- tDesc.Height = ScaleHeight - tDesc.Top
- bDefine.Left = ScaleWidth - bDefine.Width - 120
- tWord.Width = bDefine.Left - 240 - tWord.Left
- End Sub
- Sub IPPort1_DataIn (Text As String, EOL As Integer)
- Me.MousePointer = 0
- 'start of a new description...
- If tDesc = "Making request..." Then
- tDesc = ""
- MousePointer = 0
- End If
- If EOL Then Text = Text & Chr$(13) & Chr$(10)
- tDesc.SelStart = Len(tDesc)
- tDesc.SelText = Text
- End Sub
- Sub IPPort1_Disconnected (StatusCode As Integer, Description As String)
- MousePointer = 0
- End Sub
- Sub tDesc_DblClick ()
- tWord = tDesc.SelText
- bDefine = True
- 'select word
- tWord.SelStart = 0
- tWord.SelLength = Len(tWord)
- tWord.SetFocus
- End Sub
-